package com.sxzbxc.weixin.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.sxzbxc.weixin.service.DicCompaniseServiceI;
import com.sxzbxc.weixin.service.DicLineinfoServiceI;
import com.sxzbxc.weixin.service.DicMelfunctionServiceI;
import com.sxzbxc.weixin.service.DicSubstationServiceI;
import com.sxzbxc.weixin.service.SysUserServiceI;


/**
 * 用于配置中心的各个数据删除
 * @author Tom
 *
 */
@Controller
@RequestMapping("sysdeleteController")
public class SysdeleteController {

	@Autowired
	private DicCompaniseServiceI departService;
	
	@Autowired
	private DicLineinfoServiceI lineService;
	
	@Autowired
	private DicMelfunctionServiceI melfunctionService;
	
	@Autowired
	private DicSubstationServiceI substationService;
	
	@Autowired
	private SysUserServiceI sysUserService;
	
	
	/**
	 * 供电所删除
	 * @param req
	 * @param id
	 */
	@RequestMapping(params = "departDelete")
	public ModelAndView departDelete(HttpServletRequest req ,String id){
		try {
			departService.deleteByPrimaryKey(id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new ModelAndView("admin/adminList");
	}
	
	/**
	 * 线路删除
	 * @param req
	 * @param id
	 */
	@RequestMapping(params = "lineDelete")
	public ModelAndView lineDelete(HttpServletRequest req, String id){
		try {
			lineService.deleteByPrimaryKey(id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new ModelAndView("admin/adminList");
	}

	/**
	 * 故障类型删除
	 * @param req
	 * @param id
	 */
	@RequestMapping(params = "melTypeDelete")
	public ModelAndView melTypeDelete(HttpServletRequest req, String id){
		try {
			melfunctionService.deleteByPrimaryKey(id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new ModelAndView("admin/adminList");
	}

	/**
	 * 变电站删除
	 * @param req
	 * @param id
	 */
	@RequestMapping(params = "subinfoDelete")
	public ModelAndView subinfoDelete(HttpServletRequest req, String id){
		try {
			substationService.deleteByPrimaryKey(id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new ModelAndView("admin/adminList");
	}

	/**
	 * 用户
	 * @param req
	 * @param id
	 */
	@RequestMapping(params = "userDelete")
	public ModelAndView userDelete(HttpServletRequest req, String id){
		try {
			sysUserService.deleteByPrimaryKey(id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new ModelAndView("admin/adminList");
	}

}
